use crate::fasttime::b1_date::DateFT;




pub trait IYear {
    fn is_leap(&self) -> bool;
    fn days(&self) -> i32;
}


impl IYear for i32 {
    fn is_leap(&self) -> bool {
        let year = *self;
        if year % 100 == 0 {
            year % 400 == 0
        } else {
            year % 4 == 0
        }
    }
    fn days(&self) -> i32 {
        if self.is_leap() {
            366
        } else {
            365
        }
    }
}
pub fn dates_year(year: i32) -> Vec<DateFT> {
    let mut dates = vec![];

    for month in 1..=12 {
        let days = super::a2_month::days_inmonth(year, month);
        for day in 1..=days {
            dates.push(DateFT::from_ymd_unsafe(year, month, day));
        }
    }

    dates
}

pub fn dates_year_month(year: i32, month: u8) -> Vec<DateFT> {
    if month == 0 || month > 12 {
        error!("a1_year::dates_year_month input error: month == 0 || month > 12");
        return vec![];
    }
    let mut dates = vec![];
    
    let days = super::a2_month::days_inmonth(year, month);
    for day in 1..=days {
        dates.push(DateFT::from_ymd_unsafe(year, month, day));
    }

    dates
}